package com.hspedu.newData.dmsxl.动态规划.基础;

import org.junit.Test;

/**
 * @Author: yh
 * @description: 
 * @CreateTime: 2025-04-26 
 * @Version: 1.0
 */

public class LC96不同的二叉搜索树 {

    public int numTrees(int n) {


        int[] dp = new int[n+1];
        dp[0] = 1;
        for (int i = 1; i <= n; i++) {
            int sum = 0;
            for (int j = i-1; j >= 0; j--) {
                sum += dp[j]*dp[i-1-j];
            }
            dp[i] = sum;
        }

        return dp[n];
    }


    @Test
    public void test() {
        // 测试代码
        numTrees(6);
    }
}
